<?php

namespace app\index\controller;

use app\index\controller\CommonController;
use app\index\model\Article;
use app\index\model\House;

/*
 * 房抵贷
 */
class HouseController extends CommonController
{
    public function index()
    {
        //房抵贷
        $houseList = House::field('id, name, description, img')
            ->order('add_time desc')
            ->select();

        //房贷资讯
        $articleList = Article::where('artcate_id', '=', 13)
            ->field('id, title')
            ->order('add_time desc')
            ->limit(0, 12)
            ->select();

        return view('index', [
            'menuIndex' => 3,
            'houseList' => $houseList,
            'articleList' => $articleList,
        ]);
    }

    public function content()
    {
        $id = input('param.id');

        $row = House::where('id', '=', $id)->find();

        //新手贷款
        $articleList = Article::where('artcate_id', '=', 4)
            ->field('id, title')
            ->order('add_time desc')
            ->limit(0, 8)
            ->select();

        return view('content', [
            'menuIndex' => 3,
            'row' => $row,
            'articleList' => $articleList,
        ]);
    }

    public function houseList()
    {
        $houseList = House::field('id, name, description, img')
            ->order('add_time desc')
            ->paginate(10);

        return view('houselist', [
            'menuIndex' => 3,
            'houseList' => $houseList
        ]);
    }


}